#!
# demostrate how to parse the program arguments list
# 1/12/2003


use strict;
use File::Basename;

sub Usage
{
	my $program_name = basename($0);

	print "Usage:\n";
	print "$program_name featuresdir outputdir trainsize  [options]\n";
	print "trainsize can be a int(how many) or a float(0~1,the percentage)\n";
	print "Options: (which features are needed) (default: all features are used)\n";
	print "  -tf    : term frequency\n";
	print "  -fo    : first occurence\n";
	print "  -title : is in title\n";
	print "  -pos   : Part of Speech\n";
}

sub EnumFiles
{
	my($DirName)=@_;
	
	my $command = "dir $DirName\\*.* /b/a:a";
	my @list = `cmd.exe /c $command`;
	my @files;
	@files = (@files,"$DirName\\$_") foreach @list;
	chomp @files;
	return @files;
}

if(@ARGV <3)
{
	Usage;
	exit;
}



my @files = EnumFiles($ARGV[0]);
my $savedir = $ARGV[1];
my $trainsize = $ARGV[2];



my $need_tf = 0;
my $need_fo = 0;
my $need_title = 0;
my $need_pos = 0;

my $j=0;
if(@ARGV == 3) # default to use all features
{
	$need_tf = 1;
	$need_fo = 1;
	$need_title = 1;
	$need_pos = 1;		
}
else
{
	for($j=3;$j<@ARGV;$j++)
	{
		if($ARGV[$j] eq "-tf")
		{
			$need_tf = 1;
		}
		elsif($ARGV[$j] eq "-fo")
		{
			$need_fo = 1;
		}
		elsif($ARGV[$j] eq "-title")
		{
			$need_title = 1;
		}
		elsif($ARGV[$j] eq "-pos")
		{
			$need_pos = 1;
		}
		else
		{
			Usage;
			print "Pls check ur spelling!\n";
		}
		
	}
}



my $i=0;
my $size = @files;
my $filename;

if($trainsize<1)
{
	$trainsize = int (@files*$trainsize);
}
